package 简单.单值二叉树;

public class Solution1 {
    public boolean isUnivalTree(TreeNode root) {

        if (root == null) return true;
        if(root.left == null && root.right==null) return true;
        if(root.left != null && root.right == null){
            return root.left.val == root.val;
        }
        if (root.left == null && root.right != null){
            return root.right.val == root.val;
        }
        return isUnivalTree(root.left) && isUnivalTree(root.right);


    }
}
